package controllers; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import models.Bank; public class SerializableManager { public void serializeBank(Bank bank) { try { FileOutputStream fileOut = new FileOutputStream("bank.ser"); ObjectOutputStream out = new ObjectOutputStream(fileOut); out.writeObject(bank); out.close(); fileOut.close(); } catch (IOException i) { i.printStackTrace(); } } public Bank deserializeBank() { Bank e = null; try { FileInputStream fileIn = new FileInputStream("bank.ser"); ObjectInputStream in = new ObjectInputStream(fileIn); e = (Bank) in.readObject(); in.close(); fileIn.close(); } catch (IOException i) { i.printStackTrace(); } catch (ClassNotFoundException c) { System.out.println("Imm class not found"); c.printStackTrace(); } return e; } }